ISCPersistenceUnit::ReverseEngineer

Here is the signature for the ReverseEngineer function:

HRESULT ReverseEngineer ([in]ISCPropertyBag * PropertyBag,[in]VARIANT 
REoptionpath,[in] VARIANT REConnectionString,[in] VARIANT REPassword);

The following table contains the valid arguments for the ReverseEngineer function:

Parameter

Valid Type/Value

Description

PropertyBag

ISCPropertyBag * - Pointer to a Property Bag object.

Contains options for reverse engineering.

REoptionpath

VT_BSTR - Path.

Specifies the full path to the items storage for reverse engineering.

REConnectionString

VT_BSTR - Database connection string.

Identifies the database connect string.

REPassword

VT_BSTR - Connection password.

Null for windows authentication.

Identifies the password used for database connection.

The following table contains the valid arguments for the PropertyBag parameter.

Parameter

Valid Type/Value

Description

System_objects

VT_BOOL -- True or False.

Default: False

Retrieves system objects.

True: System objects are retrieved.

False: System objects are not retrieved.

Oracle_Use_DBA_Views

VT_BOOL -- True or False

Default: False. Only valid for Oracle.

Use DBA Views for reverse engineering.

True: Use DBA Views.

False: Do not use DBA Views.

Synch_Table_Filter_By_Name

VT_BSTR

Default: Null

Reverse engineers the tables that contain the input filter strings.Multiple filter strings are specified as comma separated values.

Synch_Owned_Only

VT_BOOL -- True or False.

Default: False

Retrieves tables and views of users.

True: Retrieve from current user or owners.

False: Retrieve from all.

Synch_Owned_Only_Name

VT_BSTR

Default: Null

Reverse engineers tables and views owned by the specified users.

Case_Option

25090:None

25091:lower

25092:Upper

Default: None

Specifies the case conversion option for physical names.

Logical_Case_Option

25045: None

25046: UPPER

25047: lower

25048:Mixed

Default: None

Specifies the case conversion option for logical names.

Infer_Primary_Keys

VT_BOOL-- True or False.

Default: None

Infers primary key columns for the tables that are based on defined indexes.

True: Primary Keys option is selected.

False: Primary Keys option is not selected.

Infer_Relations

VT_BOOL-- True or False.

Default: False

Infers the relationships between tables that are based on either primary key column names or defined indexes.

True: Relations Option is selected.

False: Relations Option is not selected.

Infer_Relations_Indexes

VT_BOOL-- True or False.

Set the value to Indexes or Names when Infer_Relations is set to Relations.

Default: False.

Infers the relationships from the table indexes.

True: Indexes option is selected.

False: Names option is selected.

Remove_ERwin_Generated_Triggers

VT_BOOL--True or False.

Default: True.

Removes erwin generated triggers.

True: Remove Include Generated Triggers.

False: Do not remove Include Generated Triggers.

Force_Physical_Name_Option

VT_BOOL--True or False.

Default: Force

Overrides the physical name property for all objects in logical/physical models automatically during reverse engineering.

True: Force physical name option.

False: Do not force physical name option.

Connection String

Server=<Target Server type>:<MajorVersion>:<MinorVersion>
|AUTHENTICATION=<AuthenticationType>|USER=<UserName>|
<ServerParameter>=<ServerParameterValue>

Example:

SERVER=16:10:0|AUTHENTICATION=4|USER=erwin|1=3|2=r8|3=127.0.0.1\\erwin_mart01

The following table describes the valid values for a connection string.

Parameter

Value

Description

SERVER

<TargetServerType> is an integer value.

1: Access

2: Db2

3: DB2UDB

4: Foxpro

5: Inforrmix

6: Ingres

7: ISeries

8: MySQL

9: ODBC

9: Netezza

9: PostgreSQL

9. Redshift

10: Oracle

11: Progress

12: Redbrick

13: SAS

14: SAP ASE

15: SAP IQ

16: SQLServer

17: Teradata

18: SQLAzure

19. Hive

20. MariaDB

21. Snowflake

22. Cassandra

23. MongoDB

24. Couchbase

25. AVRO

26. JSON

27. Azure Synapse

28. Neo4j

29. ArangoDB

30. Parquet

31. Amazon Keyspaces

32. Google BigQuery

33. DynamoDB

34. Databricks

Specifies the type of the database server.

AUTHENTICATION

4 or 8

4: Database authentication

8: Windows authentication

Specifies the authentication type.

User

User Name

Specifies the user name.

The following table describes the type and value of ServerParameter:

Server Parameter

Server Parameter Value

Description

1

2 or 3

2: Indicates "Use ODBC data source".

3: Indicates "Use Native Connection"

2

String

Identifies the database.

3

String

Identifies the server name.

4

String

Identifies the alternate catalog name.

5

String

Identifies the ODBC data source name.

6

String

Identifies the connection string value or DNS_URL for the database.

7

String

Identifies the access database path.

8

String

Identifies the system database path.

9

String

Identifies the password for access system database.

10

Boolean 0 or 1

0: ODBC data browse is turned off.

1: ODBC data browse is turned on.

11

Boolean 0 or 1

0: Do not use encrypted connection.

1: Use encrypted connection.

12

Boolean 0 or 1

0: Do not connect to Oracle as SYSDBA.

1: Connect to Oracle as SYSDBA.

13

Applicable only to Hive

1 or 2 or 3

1: REDB using Hive

2: REDB using MySQL Metastore

3: REDB using PostgreSQL Metastore

14

3 or 4

3: Direct connection method

4: Connection String method

For the target database, Hive, an additional server parameter, 13, is required as shown in the following example:

For REDB-PureHive:

Call oPersistenceUnit.ReverseEngineer(oPropertyBag,, "SERVER=19:2:1|AUTHENTICATION=4|USER=<hive-user>|1=2|5=<cloudera dsn>|10=0|13=1", "<hive-password>")

For REDB-Metastore MySQL:

Call oPersistenceUnit.ReverseEngineer(oPropertyBag,, "SERVER=19:2:1|AUTHENTICATION=4|USER=<mysql-user>|1=2|5=<mysql dsn>|10=0|13=2", "<mysql-password>")

For REDB-Metastore PostgreSQL:

Call oPersistenceUnit.ReverseEngineer(oPropertyBag,, "SERVER=19:2:1|AUTHENTICATION=4|USER=<postgresql-user>|1=2|5=<postgresql dsn>|10=0|13=3", "<postgresql-password>")

For REDB-Cassandra using Connection String method:

Call oPersistenceUnit.ReverseEngineer(oPropertyBag,, "SERVER=22:3:0|AUTHENTICATION=4|USER=adminNew|6=<connection_string_url>|14=4")

For REDB-MongoDB using Direct method:

Call oPersistenceUnit.ReverseEngineer(oPropertyBag,, "SERVER=22:3:0|AUTHENTICATION=4|USER=adminNew|6=<connection_string_url>|14=4")

Reverse Engineering Sample Script:

Dim oAPI
    	Set oAPI = CreateObject("erwin9.SCAPI.9.0")
        Dim oPropertyBag
	Set oPropertyBag = CreateObject("erwin9.SCAPI.PropertyBag.9.0")
        Call oPropertyBag.Add("Model_Type", "Combined")
        Call oPropertyBag.Add("Target_Server", 1075859016)
        Call oPropertyBag.Add("Target_Server_Version", 10)
        Dim oPUnitCol
        Set oPUnitCol = oApi.PersistenceUnits
        Dim oPersistenceUnit
        Set oPersistenceUnit = oPUnitCol.Create(oPropertyBag)
        'oPropertyBag = CreateObject("erwin9.SCAPI.PropertyBag.9.0")
        'oPropertyBag = oApi.ApplicationEnvironment.PropertyBag
        oPropertyBag.ClearAll()
        Call oPropertyBag.Add("System_Objects", True)
        Call oPropertyBag.Add("Oracle_Use_DBA_Views", False)
        Call oPropertyBag.Add("Synch_Owned_Only", False)
        Call oPropertyBag.Add("Synch_Owned_Only_Name", "")
        Call oPropertyBag.Add("Case_Option", 25091)
        Call oPropertyBag.Add("Logical_Case_Option", 25046)
        Call oPropertyBag.Add("Infer_Primary_Keys", False)
        Call oPropertyBag.Add("Infer_Relations", False)
        Call oPropertyBag.Add("Infer_Relations_Indexes", False)
        Call oPropertyBag.Add("Remove_ERwin_Generated_Triggers", False)
        Call oPropertyBag.Add("Force_Physical_Name_Option", False)
	 Call oPropertyBag.Add("Synch_Table_Filter_By_Name", "")
        Call oPersistenceUnit.ReverseEngineer(oPropertyBag, "c:\\re.xml", 
	 "SERVER=16:10:0|AUTHENTICATION=4|USER=erwin|1=3|2=r8|3=127.0.0.1
	 \\erwin_mart01", "ca123456")
Call oPersistenceUnit.Save("c:\\test.erwin", "OVF=Yes")

Attach NSM file with API while REDB:

An additional property,ReverseEngineerCSV, is available to attach an NSM file with API while doing REDB. This property enables you to select an NSM file for reverse engineering.

Reverse Engineering Sample Script:

Dim oAPI
        Set oAPI = CreateObject("ERwin9.SCAPI.9.0")
        Dim oPropertyBag
        Set oPropertyBag = CreateObject("ERwin9.SCAPI.PropertyBag.9.0")
        'Create LP model with Database as SQL Server 2012
        Call oPropertyBag.Add("Model_Type", "Combined")
        Call oPropertyBag.Add("Target_Server", 1075859016)
        Call oPropertyBag.Add("Target_Server_Version", 11)
        'Create Persistence Unit
        Dim oPUnitCol
        Set oPUnitCol = oApi.PersistenceUnits
        'Create Propertybag
        Dim oPersistenceUnit
        Set oPersistenceUnit = oPUnitCol.Create(oPropertyBag)
        'Clear all propertybag objects
        oPropertyBag.ClearAll()
        Call oPropertyBag.Add("System_Objects", False)
        Call oPropertyBag.Add("Oracle_Use_DBA_Views", False)
        Call oPropertyBag.Add("Synch_Owned_Only", False)
        Call oPropertyBag.Add("Synch_Owned_Only_Name", "")
        Call oPropertyBag.Add("Case_Option", 25091)
        Call oPropertyBag.Add("Logical_Case_Option", 25046)
        Call oPropertyBag.Add("Infer_Primary_Keys", False)
        Call oPropertyBag.Add("Infer_Relations", False)
        Call oPropertyBag.Add("Infer_Relations_Indexes", False)
        Call oPropertyBag.Add("Remove_ERwin_Generated_Triggers", False)
        Call oPropertyBag.Add("Force_Physical_Name_Option", False)
        'Reverse Engineer the SQL Server 2012 DB
        Call oPersistenceUnit.ReverseEngineerCSV (oPropertyBag, 
	 "C:\Users\Administrator\Desktop\NSM-API\table.xml", 
	 "C:\Users\Administrator\Desktop\NSM-API\res_demo.csv", 
	"SERVER=16:11:0|AUTHENTICATION=4|USER=sa|1=3|2=TestDG|3=localhost|11=0", 
	"Erwin123")
        'Save the RE'd model
        Call oPersistenceUnit.Save("C:\Users\Administrator\Desktop\NSM-API\
	SQS2016RECSV.erwin", "OVF=Yes")